# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=('crypt' 'libcrypt' 'libcrypt-devel')
pkgver=1.1
pkgrel=6
pkgdesc="Encryption/Decryption utility and library"
groups=('base')
arch=('i686' 'x86_64')
license=('custom')
url="http://cygwin.com/"
makedepends=('gcc' 'cvs' 'make')
source=(msysize.patch)
md5sums=('3c6928db04605cd450064b52b2af5ca0')

CVSROOT=":pserver:anoncvs:@sourceware.org:/cvs/cygwin-apps"
CVSMOD="crypt"
CVS_BRANCH="release-${pkgver//\./_}"

prepare() {
  cd ${srcdir}
  msg "Connecting to sourceware.org CVS server...."
  if [ -d $CVSMOD/CVS ]; then
    cd $CVSMOD
    cvs -z3 update -d
  else
    cvs -z3 -d $CVSROOT co -f $CVSMOD
    cd $CVSMOD
  fi

  patch -p1 -i ${srcdir}/msysize.patch
}

build() {
  cd "$srcdir/$CVSMOD"
  make CC=gcc AR=ar CFLAGS="${CFLAGS}"

  make DESTDIR=${srcdir}/dest install
}

package_crypt() {
  pkgdesc="Encryption/Decryption utility"
  depends=('libcrypt')

  mkdir -p ${pkgdir}/usr/bin

  cp -f ${srcdir}/dest/usr/bin/*.exe ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/share ${pkgdir}/usr/
}

package_libcrypt() {
  pkgesc="Encryption/Decryption library"
  groups=('libraries')
  depends=('gcc-libs')
  mkdir -p ${pkgdir}/usr/bin

  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/
}

package_libcrypt-devel() {
  pkgdesc="Libcrypt headers and libraries"
  groups=('development')
  depends=("libcrypt=${pkgver}")
  options=('staticlibs')

  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
